<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <table border="1">
      <tbody>
        <tr>
          <td>11</td>
          <td>12</td>
          <td>13</td>
          <td>14</td>
          <td>15</td>
        </tr>
        <tr>
          <td>21</td>
          <td>22</td>
          <td>23</td>
          <td>24</td>
          <td>25</td>
        </tr>
        <tr>
          <td>31</td>
          <td>32</td>
          <td>33</td>
          <td>34</td>
          <td>35</td>
        </tr>
        <tr>
          <td>41</td>
          <td>42</td>
          <td>43</td>
          <td>44</td>
          <td>45</td>
        </tr>
        <tr>
          <td>51</td>
          <td>52</td>
          <td>53</td>
          <td>54</td>
          <td>55</td>
        </tr>
      </tbody>
    </table>
    <script>
      const table = document.body.children[0];
      const rows = table.rows;
      for (let i = 0; i < rows.length; i++) {
        const cells = rows[i].cells;
        for (let j = 0; j < cells.length; j++) {
          if (i === j) {
            cells[j].style.backgroundColor = "yellow";
          }

          if (i + j === rows.length - 1) {
            cells[j].style.backgroundColor = "yellow";
          }
        }
      }
    </script>
  </body>
</html>
